drop a column in pandas

32

#To delete the column without having to reassign df
df.drop('column_name', axis=1, inplace=True) 
df.drop('column_name', axis=1, inplace=True)
#no need to reasign df
#axis 1 is columns, 0 is rows
df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index 

Comments

Submit
0 Comments